<?php
    header('Content-type:text/json');
    require "../../connection.php";
    $id = $_POST['id'];
    $option  = array("id"=>$id);
    $res = $conn->where($option)->select("goods_adv_map");
    $img_url = $res[0]['imgUrl'];
    $filepath = str_replace("/admin","..",$img_url);
    //echo json_encode($filepath);
    $result = $conn->where($option)->delete("goods_adv_map");
    if($result){
        $msg = "删除成功";
        // 删除实际文件
        delFile($filepath);
    }else{
        $msg = "删除失败";
    }
    $data = array("status"=>"1","msg"=>$msg);
    echo json_encode($data);

/***
    删除文件
    $filepath 要删除的路径下的文件

**/
     function delFile($filepath){
           if(file_exists($filepath)){
                unlink($filepath);
           }else{
                echo "文件不存在";
           }
     }

?>